<template>
  <div style="width: 100%;position: absolute;" :style="{height: (isShow?'100%':'0')}">
    <div class="dialogue_wrapper">
      <div class="dialogue_back" @click="close" v-if="isShow"></div>
      <transition name="drop">
        <div class="dialogue_content_box" @click="close" v-if="isShow">
          <div class="dialogue_content" @click.stop="stopEvent">
            <p class="close_button"><span @click="close">x</span></p>
            <slot></slot>
          </div>
        </div>
      </transition>
    </div>
  </div>
</template>

<script>
  export default {
    name: "dialogue",
    props: {
      isShow: {
        type: Boolean,
        default: true
      }
    },
    methods: {
      close() {
        this.$emit('on-close');
      },
      stopEvent() {
        console.log('stop click event');
      }
    }
  }
</script>

<style scoped lang="scss">
  .dialogue_wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
  }

  .dialogue_back {
    width: 100%;
    height: 100%;
    background-color: black;
    opacity: 0.3;
    position: absolute;
  }

  .dialogue_content_box {
    width: 100%;
    padding: 10px;
    margin-top: 10%;
    position: fixed;
    text-align: center;
  }

  .dialogue_content {
    background-color: white;
    display: inline-block;
    min-width: 20%;
    max-width: 50%;
    padding: 10px;
    border: 1px solid rgb(116, 129, 137);
  }

  .close_button {
    margin: 0;
    text-align: right;
    span {
      padding-left: 20px;
    }
  }

  .drop-enter-active {
    transition: all .5s ease;
  }

  .drop-leave-active {
    transition: all .3s ease;
  }

  .drop-enter {
    transform: translateY(-500px);
  }

  .drop-leave-active {
    transform: translateY(-500px);
  }
</style>
